home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Science / µSim 1.0b5 folder / Libs / CursorBalloon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-27  |  2.9 KB  |  99 lines  |  [TEXT/MMCC]

  1. #ifndef __FABCURSORBALLOON__
  2. #define __FABCURSORBALLOON__
  3.  
  4. /* this distinguishes a normal window from a window with objects */
  5.  
  6. enum windowclasses {
  7. kFabWindowClass = 10
  8. };
  9.  
  10. /* this is my window record, containing the standard Window Manager record,
  11. the procedures normally called when handling events (if you do not want to
  12. undertake special actions i.e. for dragging, pass nil), the number of
  13. objects, and a Handle to the objects */
  14.  
  15. typedef struct RgnBalloonCurs RgnBalloonCurs;
  16. typedef RgnBalloonCurs *RgnBalloonCursPtr;
  17. typedef RgnBalloonCursPtr *RgnBalloonCursHandle;
  18.  
  19. struct FabWindowRecord {
  20.     WindowRecord    w;
  21.     ProcPtr        activateProc,
  22.                 updateProc,
  23.                 dragProc,
  24.                 growProc,
  25.                 zoomProc,
  26.                 goAwayProc,
  27.                 contentProc;
  28.     unsigned long    objCount;
  29.     RgnBalloonCursHandle    myZones;
  30.     };
  31.  
  32. typedef struct FabWindowRecord FabWindowRecord;
  33. typedef FabWindowRecord *FabWindowPtr;
  34.  
  35. /* this is a generic object belonging to a window */
  36.  
  37. struct RgnBalloonCurs {
  38.     void (*recalcRgnProc)(FabWindowPtr, RgnBalloonCursPtr);
  39.     RgnHandle    zoneLocal;
  40.     RgnHandle    zoneGlobal;
  41.     CursHandle    curs;
  42.     unsigned long    myBalloon;
  43.     short        balloonVariant;
  44.     short        reserved; /* alignment */
  45.     };
  46.  
  47.  
  48. OSErr InstallRgnHandler(FabWindowPtr w, RgnHandle whichRgn, void (*recalcProc)(FabWindowPtr, RgnBalloonCursPtr),
  49.                         CursHandle cursor,
  50.                         unsigned long balloon, short ballnVariant);
  51. void RecalcMouseRegion(WindowPtr w, Point mouse);
  52. void ResizeObjects(FabWindowPtr w);
  53. void RecalcGlobalCoords(FabWindowPtr w);
  54. void DisposFabWindow(FabWindowPtr w);
  55. void ForceMouseMovedEvent(void);
  56.  
  57. /* useful macros */
  58.  
  59. #define toBalloon(m, i)        (((long)m << 16) + i)
  60.  
  61. #define Zones(w)            (((FabWindowPtr)w)->myZones)
  62.  
  63. #define InitFabWindow(w)    { Zones(w) = (RgnBalloonCursHandle)NewHandle(0); \
  64.                                 ((WindowPeek)w)->windowKind = kFabWindowClass; }
  65.  
  66. /* macros for setting the event handlers for the window, and
  67. prototypes of the handlers */
  68.  
  69. // void DoActivateWindow(WindowPtr w, Boolean becomingActive);
  70. #define SetActivate(w, p)    ((FabWindowPtr)w)->activateProc = (ProcPtr)(p)
  71.  
  72. // void DoUpdateWindow(WindowPtr w);
  73. #define SetUpdate(w, p)        ((FabWindowPtr)w)->updateProc = (ProcPtr)(p)
  74.  
  75. // void DoDragWindow(WindowPtr w);
  76. #define SetDrag(w, p)        ((FabWindowPtr)w)->dragProc = (ProcPtr)(p)
  77.  
  78. // void DoGrowWindow(WindowPtr w, EventRecord    *event);
  79. #define SetGrow(w, p)        ((FabWindowPtr)w)->growProc = (ProcPtr)(p)
  80.  
  81. // void DoZoomWindow(WindowPtr w);
  82. #define SetZoom(w, p)        ((FabWindowPtr)w)->zoomProc = (ProcPtr)(p)
  83.  
  84. // void DoCloseWindow(WindowPtr w);
  85. #define SetGoAway(w, p)        ((FabWindowPtr)w)->goAwayProc = (ProcPtr)(p)
  86.  
  87. // void DoContentClick(WindowPtr w, EventRecord *event);
  88. #define SetContent(w, p)    ((FabWindowPtr)w)->contentProc = (ProcPtr)(p)
  89.  
  90. #define NumObjects(w)        (((FabWindowPtr)w)->objCount)
  91. #define OneMoreObject(w)    (((FabWindowPtr)w)->objCount++)
  92.  
  93. #define IsFabWindow(w)        (((WindowPeek)w)->windowKind == kFabWindowClass)
  94.  
  95. extern RgnHandle    mouseRgn, wideOpenRgn;
  96.  
  97. #endif
  98.  
  99.